package ch.lom.clemens.android.bibliography.data;

import java.util.HashMap;
import java.util.Map;

public class MDocument {
	protected String title;
	protected String [] authors;
	protected String [] tags;
	protected String publication_outlet;
	protected String year;
	protected String docabstract;
	protected HashMap<String,String> identifiers = new HashMap<String,String>();
	protected String issn;
	protected String [] urls;
	protected String type;
	protected String notes;
	protected HashMap<String,String> discipline = new HashMap<String,String>();
	protected String pages;

	protected String m_docid;
	protected MCollection m_con;
	protected boolean m_dataavailable = false;
	
	public MDocument(MCollection con, String docid) {
		m_docid = docid;
		m_con = con;
	}
	
	protected void getData() {
		m_con.getDocument(this);
		m_dataavailable = true;
	}
	
	public String getTitle() {
		if(!m_dataavailable) getData();
		return title;
	}
	
	
	public String getAuthorsString() {
		String strAuthors = "";
		if (authors != null) {
			for (int j=0; j<authors.length; j++) {
				strAuthors += authors[j] + ", ";
			}
			if (strAuthors.length()>0) strAuthors = strAuthors.substring(0,strAuthors.length()-2);
		}
		return strAuthors;
	}

	public String[] getURLs() {
		if(!m_dataavailable) getData();
		return urls;
	}

	public String getNotes() {
		if(!m_dataavailable) getData();
		return notes;
	}

	public String getPubOutlet() {
		if(!m_dataavailable) getData();
		return publication_outlet;
	}
	
	public String [] getTags() {
		if(!m_dataavailable) getData();
		return tags;
	}

	public String getAbstract() {
		if(!m_dataavailable) getData();
		return docabstract;
	}

	public Map<String,String> getIdentifiers() {
		if(!m_dataavailable) getData();
		return identifiers;
	}

	public Map<String,String> getDiscipline() {
		if(!m_dataavailable) getData();
		return discipline;
	}
}
